﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HDAPI;
using LitJson;

public partial class Test_Scripts_Vendors : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Write("6. Getting all available vendors");
        HDBase hd = new HDBase(Request);

        if (hd.vendor())
        {
            JsonData data = hd.getVendor();
            foreach (object o in data["vendor"])
            {
                Append(InfoType.Success, Convert.ToString(o.ToString()));
            }
            Append(InfoType.Success, "API call successful.");
            Session["6"] = "<font color='green'>API call successful.</font>";
        }
        else
        {
            Append(InfoType.Error, hd.getError());
            Session["6"] = "<font color='red'>" + hd.getError() + "</font>";
        }
    }
    public void Append(InfoType tp, string information)
    {
        string color = "Green";
        if (tp == InfoType.Error)
        {
            color = "Red";
        }
        lblMessage.Text += "<font color='" + color + "'>" + information + "</font><br/>";
    }
    public enum InfoType
    {
        Error = 0,
        Success = 1
    }
}
